<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <el-input
        v-model="query['member.memberName']"
        clearable
        placeholder="用戶名"
        style="width: 185px;"
        class="filter-item"
        @keyup.enter.native="crud.toQuery"
      />
      <el-input
        v-model="query['member.phone']"
        clearable
        placeholder="聯繫電話"
        style="width: 185px;"
        class="filter-item"
        @keyup.enter.native="crud.toQuery"
      />
      <el-select
        v-model="query.growthType"
        placeholder="資產類型"
        clearable
        class="filter-item"
        @keyup.enter.native="crud.toQuery"
        @change="crud.toQuery"
      >
        <el-option
          v-for="item in dict.growthType"
          :key="item.id"
          :label="item.dictValue"
          :value="item.dictKey"
        />
      </el-select>
      <rrOperation :crud="crud" />
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        style="width: 100%;"
        stripe
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="member.memberName" label="會員名稱"       />
        <el-table-column prop="member.phone" label="會員號碼"       />
        <el-table-column prop="changeCount" label="改变数量"       />
        <el-table-column prop="changeType" label="改變類型"      >
          <template slot-scope="scope">
            {{ dict.label.changeType[scope.row.changeType] }}
          </template>
        </el-table-column>
        <el-table-column prop="createdAt" label="操作時間"       />
        <el-table-column prop="growthType" label=" 資產类型:"      >
          <template slot-scope="scope">
            {{ dict.label.growthType[scope.row.growthType] }}
          </template>
        </el-table-column>
        <el-table-column prop="operateMan" label="操作人员"       />
        <el-table-column prop="operateNote" label="操作备注"       />
        <el-table-column prop="sourceType" label="来源"      >
          <template slot-scope="scope">
            {{ dict.label.assetSourceType[scope.row.sourceType] }}
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMemberAssetLog from '@/api/ums/memberAssetLog'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'

const defaultForm = {
  changeCount: null,
  changeType: 0,
  endTime: null,
  growthType: 0,
  memberId: null,
  operateMan: null,
  operateNote: null,
  sourceType: 0
}
export default {
  name: 'MemberAssetLog',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['growthType', 'assetSourceType', 'changeType'],
  cruds() {
    return CRUD({
      title: '用户资产日志',
      url: 'memberAssetLog/page',
      sort: 'id:desc',
      crudMethod: { ...crudMemberAssetLog },
      optShow: {}
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'memberAssetLog:add'],
        edit: ['admin', 'memberAssetLog:edit'],
        del: ['admin', 'memberAssetLog:del']
      },
      rules: {}
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
